package cn.com.info;

public class GoodsInfo {
    //属性
    private String name;
    private int num1;
    private String kinds;
    private  int count;
    private double price;

    //方法
    public void setName(String name){
        this.name=name;
    }
    public String getName(){
        return name;
    }

    public void setNum1(int num1) {
        this.num1 = num1;
    }

    public int getNum1() {
        return num1;
    }

    public void setKinds(String kinds) {
        this.kinds = kinds;
    }
    public String getKinds(){
        return kinds;
    }
    public void setCount(int count){
        if (count>0){
            this.count=count;
        }else{
            this.count=1;
        }
    }
    public int getCount(){
        return count;
    }
    public void setPrice(double price){
        if (price>0){
            this.price=price;
        }else{
            System.out.println("输入错误");
        }
    }

    public double getPrice() {
        return price;
    }
    public GoodsInfo(String name,String kinds,int num1,int count,double price){
        setName(name);
        setKinds(kinds);
        setNum1(num1);
        setCount(count);
        setPrice(price);

    }

    public void find(GoodsKinds goods){
        if (goods.getName().equals(kinds) &&  goods.getNum()==num1){
            System.out.println(name+"价格为："+price+"有"+count+"个"+"总价"+price*count+"所属类别："+goods.getName());
        }
    }
}
